s = input()
sk = ""
skobka = ""
f = True
for skobka in s:
    if skobka in "}])>":
        f = False
        break
    if skobka in "({[<":
        sk = sk + skobka
    elif skobka in ")}]>":
        last = sk[-1]
        if skobka == ")" and last ==  "(":
            sk = sk[:-1]
        if skobka == "}" and last ==  "{":
            sk = sk[:-1]
        if skobka == "]" and last ==  "[":
            sk = sk[:-1]
        if skobka == ">" and last ==  "<":
            sk = sk[:-1]
if sk == "" and f = True:
    print(True)
else:
    print(False)
            
